package it.uniroma3.dia.predictors;

import it.uniroma3.dia.db.DBQueryConstant;

import java.sql.CallableStatement;
import java.sql.SQLException;

public class UserBasedPredictor extends AbstractPredictor {

	@Override
	public double ratingPrediction(int userID, int movieID, long timestamp) throws SQLException {
		int k=25;
		CallableStatement cs = connection.prepareCall(DBQueryConstant.STORED_PROCEDURE_USERBASEDPREDICTION);

		cs.setInt(1, userID);
		cs.setInt(2, movieID);
		cs.setLong(3, timestamp);
		cs.setInt(4, k);
		cs.registerOutParameter(5, java.sql.Types.DOUBLE);
		cs.execute();
		double prediction = cs.getDouble(5);
		
		cs.close();
		return prediction;
	}
}
